package com.penghaisoft.microwms.material.web.outwarehouse.service.impl;

import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;
import com.penghaisoft.microwms.common.wms.model.RawBack;
import com.penghaisoft.microwms.common.wms.model.RawStorage;
import com.penghaisoft.microwms.material.web.outwarehouse.dao.RawBackMapper;
import com.penghaisoft.microwms.material.web.outwarehouse.service.IMaterialOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: micro-wms
 * @description: 原材料出库服务
 * @author: zhangx
 * @create: 2018-05-21 14:06
 **/
@Service
public class MaterialOutServiceImpl extends BaseService implements IMaterialOutService {

    @Autowired
    private RawBackMapper rawBackMapper;

    /** 
     * @Description: 退料页面查询
     * @Param:  
     * @return:  
     * @Author: zhangx
     * @Date: 2018/5/21 14:25
     */ 
    @Override
    public Pager<RawBack> findRawBackListByCondition(int page, int rows, RawBack condition) {
        Pager<RawBack> pager = new Pager<>();
        pager.setPage(page);
        pager.setRows(rows);
        condition.preQuery();
        long size = rawBackMapper.queryCount(condition);
        List<RawBack> records = new ArrayList<RawBack>();
        if(size > 0){
            records = rawBackMapper.queryList(pager, condition);
        }
        pager.setRecords(records);
        pager.setTotalCount(size);
        return pager;
    }
}
